package com.example.harmonyos_ui.slice;

import com.example.harmonyos_ui.ResourceTable;
import ohos.aafwk.ability.AbilitySlice;
import ohos.aafwk.content.Intent;
import ohos.agp.components.Button;
import ohos.agp.components.Component;


public class LoginPromptSlice extends AbilitySlice {
    @Override
    public void onStart(Intent intent) {
        super.onStart(intent);
        super.setUIContent(ResourceTable.Layout_login_promt);
        // 获取返回按钮
        Button return_main_button = (Button)findComponentById(ResourceTable.Id_return_main_button);
        // 为按钮绑定返回主页面函数
        return_main_button.setClickedListener(this::returnMainAbility);
    }

    // 返回主页面
    private void returnMainAbility(Component component) {
        Intent intent = new Intent();
        this.present(new MainAbilitySlice(), intent);
    }

    @Override
    public void onActive() {
        super.onActive();
    }

    @Override
    public void onForeground(Intent intent) {
        super.onForeground(intent);
    }
}
